package ioc

import "fmt"

func (app *Container) SetController(obj CIocObj) {
	app.controllers[obj.Name()] = obj
}
func (app *Container) GetController(name string) CIocObj {
	v, ok := app.controllers[name]
	if !ok {
		panic(fmt.Sprintf("controller not found: %s", name))
	}
	return v
}

func (app *Container) InitController() error {
	for _, v := range app.controllers {
		if err := v.Init(); err != nil {
			return err
		}
	}
	return nil
}
